home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / win / pascal / alrmtpw.exe / ALARGBL.PAS < prev    next >
Pascal/Delphi Source File  |  1991-09-10  |  7KB  |  227 lines

  1. { File:         AlarGbl.pas  }
  2. { Created:      Mon Sep 09 00:25:27 1991  }
  3. { Description:  unit AlarGbl - Definitions of external data identifiers  }
  4. {               used in Alarm and dialog transfer record types  }
  5.  
  6. {{ STARTBLOCK   File Version Information   (REGENERATE)  }
  7. { Regenerated:  Mon Sep 09 00:25:27 1991  }
  8. { Skeleton by:  Winpro/3, a product from Louis J. Cutrona, Jr.  }
  9. {               tpw.skl version 0.05  }
  10. {{ ENDBLOCK }
  11.  
  12.  
  13. unit AlarGbl ;
  14.  
  15. interface
  16.  
  17. uses 
  18.   WinTypes,
  19.   WinProcs,
  20.   Strings,
  21.   WObjects,
  22.   StdWnds,
  23.   AlarRC ;
  24.  
  25. const
  26.  
  27.   {{ STARTBLOCK  Defines for preloaded stringtable strings (REGENERATE) }
  28.  
  29.   { ID assigned to first string }
  30.   IDS_FIRSTSTRING = 256 ;
  31.  
  32.   { Count of string identifiers to be read in at initialization }
  33.   CINITSTRINGS    = 1 ;
  34.  
  35.   { Total characters in initial strings (including null terminators)  }
  36.   CCHINITSTRINGS  = 21 ;
  37.  
  38.   { Maximum length of a stringtable string }
  39.   cchMaxRsrcString = 256 ;
  40.  
  41.   {{ ENDBLOCK }
  42.  
  43.   { Default if no time specified in WIN.INI }
  44.   gbl_pszDefault: PChar = '9101011200N' ;
  45.  
  46.  
  47. {{ STARTBLOCK  Transfer buffer record types for dialog controls  (REGENERATE) }
  48.  
  49. {-----------------------------------------------------------------------------}
  50. {{ STARTBLOCK Dialog dlg_SetAlarmTime data transfer buffer record (PRESERVE) }
  51.  
  52. type
  53.   rtdlg_SetAlarmTimeTransfer = record
  54.     szET_MONTH: array[0..2] of Char ; { Edittext }
  55.     szET_DAY: array[0..2] of Char ; { Edittext }
  56.     szET_YEAR: array[0..2] of Char ; { Edittext }
  57.     szET_HOUR: array[0..2] of Char ; { Edittext }
  58.     szET_MINUTE: array[0..2] of Char ; { Edittext }
  59.     szEM_MESSAGE: array[0..255] of Char ; { Edittext }
  60.     end ;
  61.  
  62. {{ ENDBLOCK }
  63. {-----------------------------------------------------------------------------}
  64. {{ STARTBLOCK Dialog dlg_AboutAlarm data transfer buffer record (REGENERATE) }
  65.  
  66. type
  67.   rtdlg_AboutAlarmTransfer = record
  68.     end ;
  69.  
  70. {{ ENDBLOCK }
  71. {----------------------------------------------------------------------------- }
  72.  
  73. var
  74.   { Dialog data transfer buffers for dialogs used in Alarm }
  75.   { These are initialized at the end of this unit.            }
  76.   dlg_SetAlarmTimeTransferBuf: rtdlg_SetAlarmTimeTransfer ;
  77.   dlg_AboutAlarmTransferBuf: rtdlg_AboutAlarmTransfer ;
  78.  
  79. {{ ENDBLOCK }
  80.  
  81. type
  82.   TRsrcStrings = object
  83.     hStrings: THandle ;
  84.     pszStrings: array [0..CINITSTRINGS-1] of PChar ;
  85.     szRsrcStringBuf: array[0..cchMaxRsrcString] of Char ;
  86.  
  87.     {Nothing to do for initialization, so no constructor}
  88.  
  89.     {Preload specified string table strings}
  90.     procedure Preload( hInstance: THandle ) ;
  91.     {Access preloaded string}
  92.     function psz( n: Word ): PChar ;
  93.     {Access non-preloaded string}
  94.     function pszLoad( n: Word; pszBuf: PChar ): PChar ;
  95.    end ;
  96.  
  97. var
  98.   gbl_pRsrcStrings: ^TRsrcStrings ;
  99.  
  100.   { To obtain a PChar to the preloaded string whose id is MYSTRING:   }
  101.   {    gbl_pRsrcStrings^.psz( MYSTRING ) ;                            }
  102.   { To obtain a PChar to a non-preloaded string whose id is MYSTRING: }
  103.   {    gbl_pRsrcStrings^.pszLoad( MYSTRING, nil ) ;                   }
  104.   { To load a non-preloaded string whose id is MYSTRING into a buffer }
  105.   { identified by pszBuf of type PChar:                               }
  106.   {    gbl_pRsrcStrings^.pszLoad( MYSTRING, pszBuf ) ;                }
  107.  
  108.   gbl_cAlarmSet: Char ;  {Y means set; N means not set}
  109.  
  110.   { When the alarm should go off }
  111.   gbl_wYearAlarm: Word ;
  112.   gbl_wMonthAlarm: Word ;
  113.   gbl_wDayAlarm: Word ;
  114.   gbl_wHourAlarm: Word ;
  115.   gbl_wMinuteAlarm: Word ;
  116.  
  117.   { What time it is now }
  118.   gbl_wYearNow: Word ;
  119.   gbl_wMonthNow: Word ;
  120.   gbl_wDayNow: Word ;
  121.   gbl_wHourNow: Word ;
  122.   gbl_wMinuteNow: Word ;
  123.  
  124.  
  125. implementation
  126.  
  127. procedure TRsrcStrings.Preload( hInstance: THandle ) ;
  128. var
  129.   pch:          PChar ;
  130.   cchRemaining: Integer ;
  131.   i:            Integer ;
  132.   cch:          Integer ;
  133. begin
  134.   cchRemaining := CCHINITSTRINGS ;
  135.   hStrings := LocalAlloc( lmem_Fixed, cchRemaining ) ;
  136.   if hStrings <> 0 then
  137.   begin
  138.     pch := PChar( Ptr( Seg( pch ), hStrings ) ) ;
  139.     i := IDS_FIRSTSTRING ;
  140.     while i < IDS_FIRSTSTRING + CINITSTRINGS do
  141.     begin
  142.       if cchRemaining > 0 then
  143.       begin
  144.         cch := 1 + LoadString( hInstance, i, pch, cchRemaining ) ;
  145.         pszStrings[ i - IDS_FIRSTSTRING ] := pch ;
  146.         pch := pch + cch ;
  147.         cchRemaining := cchRemaining - cch ;
  148.       end ;
  149.       i := i + 1 ;
  150.     end ;
  151.   end
  152.   else { Allocation failed }
  153. end ;
  154.  
  155. function TRsrcStrings.psz( n: Word ): PChar ;
  156. begin
  157.   psz := pszStrings[ n - IDS_FIRSTSTRING ] ;
  158. end ;
  159.  
  160.  
  161. {Load a string from the resource file.}
  162. {  pszBuf points to the buffer to receive the string.  }
  163. {    If pszBuf is null, the string will be placed in a }
  164. {    reusable buffer.                                  }
  165. {  It is the caller's responsibility to ensure that    }
  166. {    the string will not overrun the buffer.           }
  167. {  Returns a pointer to the loaded string.             }
  168. function TRsrcStrings.pszLoad( n: Word; pszBuf: PChar ): PChar ;
  169. begin
  170.   if pszBuf = nil then
  171.     pszBuf := @szRsrcStringBuf ;
  172.   LoadString( hInstance, n, pszBuf, cchMaxRsrcString ) ;
  173.   pszLoad := pszBuf ;
  174. end ;
  175.  
  176.  
  177. { Helper routine for initializing list boxes and combo boxes }
  178. procedure LoadBoxStrings( pArray: PCollection; wFrom, wTo: Word ) ;
  179. var
  180.   i: Word ;
  181. begin
  182.   for i := wFrom to wTo do
  183.   begin
  184.     pArray^.Insert( StrNew( gbl_pRsrcStrings^.pszLoad( i, PChar(nil) ) ) ) ;
  185.   end ;
  186. end ;
  187.  
  188.  
  189. { Unit AlarGbl initialization. }
  190. begin
  191.   { Create string table resource manager object }
  192.   { No special initialization required          }
  193.   New( gbl_pRsrcStrings ) ;
  194.  
  195.   { Initialize alarm state }
  196.   gbl_cAlarmSet := 'N' ;
  197.  
  198.  
  199.   { Initialize dialog data transfer buffers }
  200.  
  201.   {---------------------------------------------------------------------------}
  202.   {{ STARTBLOCK Initialize transfer buffer for Dialog dlg_SetAlarmTime (REGENERATE) }
  203.   with dlg_SetAlarmTimeTransferBuf do
  204.   begin
  205.     StrCopy( szET_MONTH, '' ) ;     { Edittext }
  206.     StrCopy( szET_DAY, '' ) ;     { Edittext }
  207.     StrCopy( szET_YEAR, '' ) ;     { Edittext }
  208.     StrCopy( szET_HOUR, '' ) ;     { Edittext }
  209.     StrCopy( szET_MINUTE, '' ) ;     { Edittext }
  210.     StrCopy( szEM_MESSAGE, '' ) ;     { Edittext }
  211.     end ;
  212.  
  213.   {{ ENDBLOCK }
  214.   {---------------------------------------------------------------------------}
  215.   {{ STARTBLOCK Initialize transfer buffer for Dialog dlg_AboutAlarm (REGENERATE) }
  216.   with dlg_AboutAlarmTransferBuf do
  217.   begin
  218.     end ;
  219.  
  220.   {{ ENDBLOCK }
  221. {----------------------------------------------------------------------------- }
  222.  
  223. end.
  224.  
  225.  
  226. {   E N D   O F   F I L E   AlarGbl }
  227.